home *** CD-ROM | disk | FTP | other *** search
- /*.............................. EQUALIZE.C ................. 7-31-94 ....*/
- /* Histogram Equalization demo program. */
- /*..........................................................................*/
- #include <stdio.h>
- #include<conio.h>
- #include<math.h>
- #include<limits.h>
- #include<malloc.h>
-
- #include <tiff.h> /* Required to support TIFF256 Graphics Library */
- #include <vsa.h> /* Required to support VSA256 Graphics Library */
- #include <vsa_font.h> /* Required to support VSA256 Graphics Library */
-
- #ifndef _MSC_VER
- /*..... This is line for Borland C Only ! .....*/
- extern unsigned _stklen = 13000;
- #endif
-
- void show_hist(int,int,long *,float);
- void hist_image(unsigned char huge *, unsigned char *, long *, int);
- void hist_display(int, int, int, int, unsigned char *, long *, int);
- void histeq(unsigned char *,long *,double, int);
- int image_stats(int, int);
- void color_bar(int,int);
- void update_message(int,int,int,char *);
- void clear_text_area(int,int,int,int);
- void vsa_get_input(char *);
- void error_message(int,int,int,int);
-
- void main(int argc, char *argv[])
- {
- int a,b,r0,c0,i,error,vmode;
- long hist[256],save_hist[256];
- unsigned xx,yy,x0,y0;
- char filename[100],text[100], key;
- unsigned char lut[768], save_lut[768];
- double power;
- x0 = 3;
- y0 = 3;
- if(argc > 1)
- /*.............................................................*/
- /* If specified, set requested video mode. */
- /*.............................................................*/
- {
- sscanf(argv[1],"%x",&vmode);
- if(vsa_init(vmode) != 0)
- {
- printf("Can't set Requested VESA video mode!\n");
- printf("Is VESA BIOS Extension TSR loaded?\n");
- return;
- }
- }
- else
- /*.............................................................*/
- /* Otherwise set highest video resolution available. */
- /*.............................................................*/
- {
- if(vsa_init(0x105) != 0) /* 1024 x 768 x 256 */
- if(vsa_init(0x103) != 0) /* 800 x 600 x 256 */
- if(vsa_init(0x101) != 0) /* 640 x 480 x 256 */
- if(vsa_init(0x100) != 0) /* 640 x 400 x 256 */
- {
- printf("Can't set VESA video mode!\n");
- printf("Is VESA BIOS Extension TSR loaded?\n");
- return;
- }
- }
- xx = XResolution;
- yy = YResolution;
- vsa_set_text_cursor_mode(1);
- r0 = 0.85*YCharResolution;
- c0 = 0.5*XCharResolution - 17;
- /*..........................................................................*/
- /* Set the color look up table with a 8 bit RGB palette and also set */
- /* the prime colors. */
- /*..........................................................................*/
- tf_set_true_color_mode(2,255,50);
- tf_set_prime_colors();
- /*..........................................................................*/
- /* Draw Frame around screen. */
- /*..........................................................................*/
- vsa_set_color(TF_Blue);
- vsa_move_to(0,0);
- vsa_rect(XResolution-1,YResolution-1);
- HERE:
- a = .125*xx;
- b = .91*yy;
- color_bar(a,b);
- /*..........................................................................*/
- /* Wait for any key to continue; if ESC key, quit program. */
- /*..........................................................................*/
- update_message(c0*XCharSize,r0*YCharSize,TF_Yellow,
- "Press ESC to exit, Any other key to continue ... ");
- key = getch();
- if(key == 27)
- goto BAIL;
- update_message(c0*XCharSize,(r0-1)*YCharSize,TF_Red," ");
- /*..........................................................................*/
- /* Open TIFF File. */
- /*..........................................................................*/
- FILENAME:
- update_message(c0*XCharSize,r0*YCharSize,TF_Green,"Input full Filename: ");
- vsa_get_input(filename);
- error = tf_open_file(filename);
- if(error == -1)
- {
- update_message(c0*XCharSize,(r0-1)*YCharSize,TF_Red,"Can't Find Specified File! ... Try Again. ");
- goto HERE;
- }
- /*..........................................................................*/
- /* Get TIFF File information. */
- /* Also Provide friendly error messages! */
- /*..........................................................................*/
- error = tf_get_file_info();
- if(error)
- {
- error_message(0,error,c0,r0-1);
- goto NOTSUPPORTED;
- }
- /*..........................................................................*/
- /* Prior to reading the image information, set defaults for all globals. */
- /*..........................................................................*/
- tf_set_defaults();
- /*..........................................................................*/
- /* Read image information. Globals are set, pointers to image data are */
- /* extracted. Also Provide friendly error messages! */
- /*..........................................................................*/
- error = tf_read_ifd();
- if(error)
- {
- error_message(1,error,c0,r0-1);
- goto NOTSUPPORTED;
- }
- /*..........................................................................*/
- /* Display TIFF image starting at (x0,y0). */
- /*..........................................................................*/
- if(TF_SamplesPerPixel == 3)
- update_message(c0*XCharSize,(r0-1)*YCharSize,TF_Red,"Please Wait - Calculating ADAPTIVE Palette. ");
- if(tf_display_ifd(x0,y0) != 0)
- {
- update_message(c0*XCharSize,(r0-1)*YCharSize,TF_Red,"Low Memory: Turning Adaptive Palette OFF! ");
- tf_set_true_color_mode(1,255,50);
- tf_display_ifd(x0,y0);
- tf_set_true_color_mode(2,255,50);
- }
- update_message(c0*XCharSize,(r0-1)*YCharSize,TF_Red," ");
- /*..........................................................................*/
- /* Restore Prime Color Values. */
- /*..........................................................................*/
- tf_set_prime_colors();
- /*..........................................................................*/
- /* Frame new image. */
- /*..........................................................................*/
- vsa_set_color(TF_White);
- vsa_move_to(x0-2,y0-2);
- vsa_rect(x0+(unsigned)TF_ImageWidth+1,y0+(unsigned)TF_ImageLength+1);
- vsa_set_color(TF_Black);
- vsa_move_to(x0-1,y0-1);
- vsa_rect(x0+(unsigned)TF_ImageWidth,y0+(unsigned)TF_ImageLength);
- /*..........................................................................*/
- /* Redraw Frame around screen. */
- /*..........................................................................*/
- vsa_set_color(TF_Blue);
- vsa_move_to(0,0);
- vsa_rect(XResolution-1,YResolution-1);
- /*..........................................................................*/
- /* Update Image Statistics */
- /*..........................................................................*/
- image_stats(XResolution - 255,150);
- /*..........................................................................*/
- /* Compute Histogram of image and display. */
- /*..........................................................................*/
- vsa_read_color_block(0,256,save_lut);
- hist_display(x0,y0,(int)(x0+TF_ImageWidth-1),(int)(y0+TF_ImageLength-1),
- save_lut,save_hist,0);
- show_hist(XResolution-258,3,save_hist,0.3);
- update_message(c0*XCharSize,(r0+1)*YCharSize,TF_White,"Hit any key to Equalize. ");
- getch();
- update_message(c0*XCharSize,(r0+2)*YCharSize,TF_White,"Hit Up/Down arrows to change 'Power', ESC to Quit.");
- power = 0.0;
- key = 0;
- while(key != 27)
- {
- for(i=0;i<768;i++)
- lut[i] = save_lut[i];
- for(i=0;i<256;i++)
- hist[i] = save_hist[i];
- histeq(lut,hist,power,0);
- vsa_write_color_block(0,256,lut);
- tf_set_prime_colors(); /* Should do this whenever LUT is reloaded*/
- show_hist(XResolution-258,3,hist,0.3);
- sprintf(text,"Equalized with 'Power' = %f ",power);
- update_message(c0*XCharSize,(r0+1)*YCharSize,TF_White,text);
- key = getch();
- if((key == 0) || (key == 0xe))
- {
- key = getch();
- if(key == 72) power += 0.1;
- if(key == 80) power -= 0.1;
- if(power > 4.0) power = 4.0;
- if(power < -4.0) power = -4.0;
- }
- }
- update_message(c0*XCharSize,(r0+1)*YCharSize,TF_White,"Saving Image as NEW.TIF ");
- update_message(c0*XCharSize,(r0+2)*YCharSize,TF_White," ");
- tf_save_file(x0,y0,x0+(int)TF_ImageWidth-1,y0+(int)TF_ImageLength-1,
- "new.tif");
- update_message(c0*XCharSize,(r0+1)*YCharSize,TF_White," ");
- /*..........................................................................*/
- /* Close opened TIFF file. */
- /*..........................................................................*/
- NOTSUPPORTED:
- tf_close_file();
- goto HERE;
- /*..........................................................................*/
- /* Restore text video mode and Bail Out. */
- /*..........................................................................*/
- BAIL:
- vsa_set_svga_mode(0x3);
- tf_about();
- getch();
- vsa_init(0x3);
- return; /*..... End main .....*/
- }
-
-
- image_stats(int x0,int y0)
- {
- char text[100];
- unsigned char row,col;
-
- row = y0/YCharSize;
- col = x0/XCharSize;
-
- sprintf(text,"Width = %d ",TF_ImageWidth);
- update_message(col*XCharSize,row*YCharSize,TF_White,text);
- row++;
- sprintf(text,"Length = %d ",TF_ImageLength);
- update_message(col*XCharSize,row*YCharSize,TF_White,text);
- row++;
- if(TF_PhotometricInterpretation < 2)
- {
- update_message(col*XCharSize,row*YCharSize,TF_White,"Color Model = Bilevel or");
- row++;
- update_message(col*XCharSize,row*YCharSize,TF_White," GrayScale ");
- row++;
- sprintf(text,"%d Bits Per Pixel ",TF_BitsPerSample[0]);
- update_message(col*XCharSize,row*YCharSize,TF_White,text);
- row++;
- }
- if(TF_PhotometricInterpretation == 2)
- {
- update_message(col*XCharSize,row*YCharSize,TF_White,"Color Model = True Color");
- row++;
- update_message(col*XCharSize,row*YCharSize,TF_White,"24 Bits Per Pixel ");
- row++;
- update_message(col*XCharSize,row*YCharSize,TF_White,"(8 bits each R,G,B) ");
- row++;
- }
- if(TF_PhotometricInterpretation == 3)
- {
- update_message(col*XCharSize,row*YCharSize,TF_White,"Color Model = Palette ");
- row++;
- sprintf(text,"%d Bits Per Pixel ",TF_BitsPerSample[0]);
- update_message(col*XCharSize,row*YCharSize,TF_White,text);
- row++;
- update_message(col*XCharSize,row*YCharSize,TF_White," ");
- row++;
- }
- if(TF_PhotometricInterpretation > 3)
- update_message(col*XCharSize,row*YCharSize,TF_White,"Color Model = Unknown ");
- return 0;
- }
-
- void show_hist(int x0,int y0,long *hist,float power)
- {
- int i,height;
- long max;
- float norm;
- /*..........................................................................*/
- /* Find max HIST[] value for auto scaling. */
- /*..........................................................................*/
- max = 0;
- for(i=0;i<256;i++)
- if(hist[i] > max)
- max = hist[i];
- if(max !=0)
- norm = 127.0/pow(max,power);
- /*..........................................................................*/
- /* Clear histogram display. */
- /*..........................................................................*/
- vsa_set_color(TF_Black);
- vsa_move_to(x0,y0);
- vsa_rect_fill(x0+255,y0+127);
- /*..........................................................................*/
- /* Draw box */
- /*..........................................................................*/
- vsa_set_color(TF_White);
- vsa_move_to(x0-1,y0-1);
- vsa_rect(x0+256,y0+128);
- vsa_set_viewport(x0,y0,x0+255,y0+127);
- /*..........................................................................*/
- /* Draw histogram within box area. Use a log scale for vertical axis. */
- /*..........................................................................*/
- vsa_set_color(TF_Orange);
- for(i=0;i<256;i++)
- {
- if(hist[i] !=0)
- height = y0+127-norm*pow(hist[i],power);
- else
- height = y0+127;
- vsa_move_to(x0+i,y0+127);
- vsa_line_to(x0+i,height);
- }
- vsa_set_viewport(0,0,XResolution-1,YResolution-1);
- return;
- }
-
-
- /*........................ HIST_IMAGE.C ........... 6-8-94 ....*/
- /* This routine computes the monochrome amplitude histogram of */
- /* an image defined by the 'image' array. The data in 'image' */
- /* is 8 bits per pixels so the 'hist' array is only 256 */
- /* elements deep. Upon returning from this routine, each */
- /* element of 'hist' contains the count (or frequency) of */
- /* occurance of pixels in the image with amplitude defined by */
- /* the index of that element. The histogram is computed by */
- /* taking into account the values in the Color Look Up Table */
- /* (CLUT). Therefore, this routine works with all 8 bit image,*/
- /* not just gray scale ones with linear CLUTs. */
- /* If 'mode' = 0, the pixel amplitude is computed as the */
- /* Root of the Sum of the Squares (RSS) of R, G, and B. */
- /* Otherwise its computed as the max of R, G, or B. */
- /* */
- /* NOTE: Where ever you see 0.5 being added in a calculation, */
- /* the reason is so that the results are rounded to the */
- /* nearest integer. */
- /*.............................................................*/
- void hist_image(unsigned char huge *image,
- unsigned char *lut,long *hist, int mode)
- {
- int width,height,i,j,amp;
- long n;
- long temp[256];
- float f_amp,red,grn,blu;
- n = 0;
- /*.............................................................*/
- /* Read out the width and Height of image. */
- /*.............................................................*/
- width = *((int huge *)image);
- image += 2;
- height = *((int huge *)image);
- image += 2;
- /*.............................................................*/
- /* Clear out TEMP array */
- /*.............................................................*/
- for(i=0;i<256;i++)
- temp[i] = 0;
- /*.............................................................*/
- /* Clear out HIST array */
- /*.............................................................*/
- for(i=0;i<256;i++)
- hist[i] = 0;
- /*.............................................................*/
- /* Now compute the total pixel count per CLUT address */
- /* (temp[i]). */
- /*.............................................................*/
- for(j=0;j<height;j++)
- for(i=0;i<width;i++)
- {
- temp[image[n]]++;
- n++;
- }
- /*.............................................................*/
- /* Now compute histogram. Do so by computing an average */
- /* amplitude (amp) for each CLUT entry (i). Then take the */
- /* total number of pixels for each CLUT entry (temp[i]) and */
- /* add it to the histogram array (hist[amp]). */
- /*.............................................................*/
- for(i=0;i<256;i++)
- {
- red = lut[3*i+0];
- grn = lut[3*i+1];
- blu = lut[3*i+2];
- /*..... if mode = 0, Amplitude = SQRT(R^2+G^2+B^2) .....*/
- if(mode == 0)
- {
- f_amp = 255.0*sqrt(red*red+grn*grn+blu*blu)/109.2;
- amp = (int)(f_amp+0.5);
- }
- /*..... if mode = 1, Amplitude = MAX of R, G, or B .....*/
- else
- {
- amp = red;
- if(grn > amp)
- amp = grn;
- if(blu > amp)
- amp = blu;
- /*..... increase range scale: 0 thru 255 (was 0 to 63) .....*/
- amp = 4.05*(float)amp;
- }
- hist[amp] += temp[i];
- }
- return;
- } /*.... END hist_image .....*/
-
- /*..................... HIST_DISPLAY.C ............ 6-8-94 ....*/
- /* This routine computes the monochrome amplitude histogram of */
- /* an image defined by the display contained within the 'x0,y0'*/
- /* to 'x1,y1' screen rectangle. The data in 'image' is 8 bits */
- /* per pixels so the 'hist' array is only 256 elements deep. */
- /* Upon returning from this routine, each element of 'hist' */
- /* contains the count (or frequency) of occurance of pixels in */
- /* the image with amplitude defined by the index of that */
- /* element. */
- /* The histogram is computed by taking into account the */
- /* values in the Color Look Up Table (CLUT). Therefore, this */
- /* routine works with all 8 bit image, not just gray scale ones*/
- /* with linear CLUTs. */
- /* If 'mode' = 0, the pixel amplitude is computed as the */
- /* Root of the Sum of the Squares (RSS) of R, G, and B. */
- /* Otherwise its computed as the max of R, G, or B. */
- /* */
- /* NOTE: Where ever you see 0.5 being added in a calculation, */
- /* the reason is so that the results are rounded to the */
- /* nearest integer. */
- /*.............................................................*/
- void hist_display(int x0, int y0, int x1, int y1,
- unsigned char *lut, long *hist, int mode)
- {
- unsigned char array[1280];
- int width,i,j,amp;
- long temp[256];
- float f_amp,red,grn,blu;
- /*.............................................................*/
- /* Compute the width of image. */
- /*.............................................................*/
- width = x1 - x0 + 1;
- /*.............................................................*/
- /* Clear out TEMP array */
- /*.............................................................*/
- for(i=0;i<256;i++)
- temp[i] = 0;
- /*.............................................................*/
- /* Clear out HIST array */
- /*.............................................................*/
- for(i=0;i<256;i++)
- hist[i] = 0;
- /*.............................................................*/
- /* Now compute the total pixel count per CLUT address */
- /* (temp[i]). */
- /*.............................................................*/
- for(j=y0;j<y1+1;j++)
- {
- vsa_get_raster_line(x0,x1,j,array);
- for(i=0;i<width;i++)
- temp[array[i]]++;
- }
- /*.............................................................*/
- /* Now compute histogram. Do so by computing an average */
- /* amplitude (amp) for each CLUT entry (i). Then take the */
- /* total number of pixels for each CLUT entry (temp[i]) and add*/
- /* it to the histogram array (hist[amp]). */
- /*.............................................................*/
- for(i=0;i<256;i++)
- {
- red = lut[3*i+0];
- grn = lut[3*i+1];
- blu = lut[3*i+2];
- /*..... if mode = 0, Amplitude = SQRT(R^2+G^2+B^2) .....*/
- if(mode == 0)
- {
- f_amp = 255.0*sqrt(red*red+grn*grn+blu*blu)/109.2;
- amp = (int)(f_amp+0.5);
- }
- /*..... if mode = 1, Amplitude = MAX of R, G, or B .....*/
- else
- {
- amp = red;
- if(grn > amp)
- amp = grn;
- if(blu > amp)
- amp = blu;
- /*..... increase range scale: 0 thru 255 (was 0 to 63) .....*/
- amp = 4.05*(float)amp;
- }
- hist[amp] += temp[i];
- }
- return;
- } /*.... END hist_display .....*/
-
- /*........................... HISTEQ.C ........... 6-8-94 .....*/
- /* This routine performs the Histogram Equalization process. */
- /* When calling this routine 'lut' holds the current image look*/
- /* up table, and 'hist' holds the current image histogram. */
- /* both 'lut' and 'hist' are updated with the new values prior */
- /* to returning to the calling routine. Note that the image's */
- /* stored pixel values are not affected by equalization. */
- /* The strength parameter 'n' determines how equalization */
- /* distribute pixels. A value of 0.0 preserves the original */
- /* pixel density profile while spreading it to fit between */
- /* pixel amplitude 0 and pixel amplitude 255. A stength of 1.0*/
- /* results in uniform pixel distribution (like comercial */
- /* software packages). */
- /* If 'mode' = 0, the pixel amplitude is computed as the */
- /* Root of the Sum of the Squares (RSS) of R, G, and B. */
- /* Otherwise its computed as the max of R, G, or B. */
- /* */
- /* NOTE: Where ever you see 0.5 being added in a calculation, */
- /* the reason is so that the results are rounded to the */
- /* nearest integer. */
- /*.............................................................*/
- void histeq(unsigned char *lut, long *hist,double n,
- int mode)
- {
- int i,amp,max_amp;
- float norm,scale[256],factor,f_amp,red,grn,blu;
- unsigned temp[256];
- /*.............................................................*/
- /* Generate the 'scale' array such that for a given index (i) */
- /* into the array (corresponding to a pixel amplitude of i) */
- /* the 'scale[i]' value is the cumulative sum of number of */
- /* pixels whose amplitude are 'i' or less (the sum is */
- /* discounted or inflated by the strength factor 'n'). */
- /* Also clear out 'temp[]' so it can be updated later. */
- /*.............................................................*/
- if(hist[0] !=0)
- scale[0] = pow(hist[0],n);
- else
- scale[0] = 0;
- for(i=1;i<256;i++)
- {
- if(hist[i] !=0)
- scale[i] = scale[i-1] + pow(hist[i],n);
- else
- scale[i] = scale[i-1];
- }
- for(i=0;i<256;i++)
- temp[i] = 0;
- /*.............................................................*/
- /* Normalize 'scale' array so that max value is 255.0 */
- /*.............................................................*/
- norm = 255.0/scale[255];
- for(i=0;i<256;i++)
- scale[i] *= norm;
- /*.............................................................*/
- /* Perform the equalization by "shifting" each CLUT entry */
- /* brightness level up or down such that for a pixel of */
- /* amplitude AMP, its new amplitude will be equal to */
- /* 'scale[AMP]'. */
- /*.............................................................*/
- for(i=0;i<256;i++)
- {
- red = lut[3*i+0];
- grn = lut[3*i+1];
- blu = lut[3*i+2];
- /*..... if mode = 0, Amplitude = SQRT(R^2+G^2+B^2) .....*/
- if(mode == 0)
- {
- f_amp = 255.0*sqrt(red*red+grn*grn+blu*blu)/109.2;
- amp = (int)(f_amp+0.5);
- }
- /*..... if mode = 1, Amplitude = MAX of R, G, or B .....*/
- else
- {
- max_amp = red;
- if(grn > max_amp)
- max_amp = grn;
- if(blu > max_amp)
- max_amp = blu;
- /*..... increase range scale: 0 thru 255 (was 0 to 63) .....*/
- amp = 4.05*(float)max_amp;
- }
-
- /*.............................................................*/
- /* Figure a scale factor such that pixels of amplitude AMP will*/
- /* have a new amplitude equal to 'scale[AMP]'. */
- /*.............................................................*/
- if(amp != 0)
- factor = scale[amp]/(float)amp;
- else
- factor = 0;
- /*.............................................................*/
- /* Now scale red, green, and blue amplitudes by the computed */
- /* scale factor. In 'mode' = 0, it is possible that the factor*/
- /* will cause one of these color values to exceed 63. In this */
- /* case the values are clamped to 63.This will cause some */
- /* minor color drift in the brighter non white pixels but it */
- /* should not be noticable. The alternative would be to scale */
- /* down the brightness of the whole pixel, or the whole image. */
- /* Neither of these two options seemed any more desirable. */
- /*.............................................................*/
- lut[3*i+0] = (int)((float)lut[3*i+0]*factor + 0.5);
- lut[3*i+1] = (int)((float)lut[3*i+1]*factor + 0.5);
- lut[3*i+2] = (int)((float)lut[3*i+2]*factor + 0.5);
- if(lut[3*i+0] > 63) lut[3*i+0] = 63;
- if(lut[3*i+1] > 63) lut[3*i+1] = 63;
- if(lut[3*i+2] > 63) lut[3*i+2] = 63;
- temp[(int)(factor*amp+0.5)] += hist[amp];
- }
- /*.............................................................*/
- /*Update histogram array with new, equalized, histogram values.*/
- /*.............................................................*/
- for(i=0;i<256;i++)
- hist[i] = temp[i];
- return;
- } /*.... END histeq .....*/
-
- void color_bar(x0,y0)
- int x0,y0;
- {
- int i;
- unsigned xx,yy,a,b;
- float c;
- xx = XResolution;
- yy = YResolution;
- /*..........................................................................*/
- /* Draw outline for color bar. */
- /*..........................................................................*/
- vsa_set_color(15);
- vsa_move_to(x0-1,y0-1);
- a = .75*xx;
- b = .065*yy;
- vsa_rect(x0+a+1,y0+b+1);
- c = (float)a/256;
- for(i=0;i<256;i++)
- {
- vsa_set_color((unsigned char)i);
- vsa_move_to(x0+(unsigned)(i*c),y0);
- vsa_rect_fill(x0+(unsigned)(c+i*c),y0+b);
- }
- return;
- }
-
- void update_message(int x0,int y0,int color,char *text)
- {
- clear_text_area(x0,y0,51,TF_Black);
- vsa_write_string(x0,y0,color,text);
- vsa_set_color(color);
- return;
- }
-
- void clear_text_area(int x0,int y0,int length,int color)
- {
- vsa_set_color(color);
- vsa_move_to(x0,y0);
- vsa_rect_fill(x0+length*XCharSize-1,y0+YCharSize-1);
- return;
- }
-
- /*.......................... VSA_GET_INPUT .................... 6-25-94 ....*/
- /* This routine reads the keyboard input and echos it to the screen until */
- /* a carriage return is entered. Then the whole text string is returned */
- /* via 'text'. */
- /*..........................................................................*/
- void vsa_get_input(char *text)
- {
- int i,x,y;
- char key;
- vsa_get_text_cursor(&x,&y);
- i=0;
- text[0] = 0;
- while((key = getch()) != 13) /* Do until a return is hit. */
- {
- if(key != 8)
- { /* If not a back space */
- text[i] = key; /* add key entry to string. */
- text[i+1] = 0;
- vsa_write_string(x,y,TF_White,text);/* Echo the updated string. */
- i++;
- }
- else
- { /* If a back space */
- if(i > 0) i --; /* delete last key entry. */
- text[i] = 92;
- vsa_write_string(x,y,TF_White,text);/* Echo the updated string. */
- text[i] = 0;
- }
- }
- return;
- }
-
- void error_message(int stage,int error,int col,int row)
- {
- int x,y;
- x = col*XCharSize;
- y = row*YCharSize;
- if(stage == 0)
- {
- if(error == 1)
- update_message(x,y,TF_Red,"File Read Error! ");
- if(error == 2)
- update_message(x,y,TF_Red,"File Shorter Than Expected! ");
- if(error == 3)
- update_message(x,y,TF_Red,"Bad TIFF File! ");
- }
- if(stage == 1)
- {
- if(error == 1)
- update_message(x,y,TF_Red,"NULL TIFF file Pointer! ");
- if(error == 2)
- update_message(x,y,TF_Red,"Error Seeking in File! ");
- if(error == 3)
- update_message(x,y,TF_Red,"File Read error! ");
- if(error == 4)
- update_message(x,y,TF_Red,"Greater than 8 Bit Palette Pixels Not Supported!");
- if(error == 5)
- update_message(x,y,TF_Red,"Samples Per Pixel > 3 Not Supported! ");
- if(error == 6)
- update_message(x,y,TF_Red,"Only 8x8x8 Bit True Color Pixels Supported! ");
- if(error == 7)
- update_message(x,y,TF_Red,"Compressed TIFF data Not Supported! ");
- if(error == 8)
- update_message(x,y,TF_Red,"This Photometric Interpretation Not Supported!");
- if(error == 9)
- update_message(x,y,TF_Red,"Currently Only Support up to 1024 Strips! ");
- if(error == 10)
- update_message(x,y,TF_Red,"Samples Per Pixel > 3 Not Supported! ");
- if(error == 11)
- update_message(x,y,TF_Red,"Currently Only Support up to 1024 Strips! ");
- if(error == 12)
- update_message(x,y,TF_Red,"This Planar Configuration Not Supported! ");
- if(error == 13)
- update_message(x,y,TF_Red,"This Predictor Not Supported! ");
- if(error == 14)
- update_message(x,y,TF_Red,"Color Map Size > 256 Not Supported! ");
- }
- return;
- }
-